import request from '@/config/axios'
import type {
  SiteBaseConfigReqVO,
  SiteVO,
  SitePageReqVO,
  SiteExcelReqVO,
  SiteDefTplQueryVO,
  SiteDefTplReqVO
} from './types'

// 查询站点列表
export const getSiteListApi = async (params: SitePageReqVO) => {
  return await request.get({ url: '/cms/site/getList', params })
}

// 查询（精简)列表
export const listSimpleSiteApi = async () => {
  return await request.get({ url: '/cms/site/list-all-simple' })
}
//查询有权限的站群
export const listOwnerSiteApi = async () => {
  return await request.get({ url: '/cms/site/getOwnerSiteList' })
}
//查询允许推送的站群
export const listAllowPushSiteApi = async () => {
  return await request.get({ url: '/cms/site/getAllowPushSiteList' })
}
// 查询站点详情
export const getSiteApi = async (id: number) => {
  return await request.get({ url: '/cms/site/get?id=' + id })
}

// 新增站点
export const createSiteApi = async (data: SiteVO) => {
  return await request.post({ url: '/cms/site/create', data })
}

// 修改站点
export const updateSiteApi = async (data: SiteVO) => {
  return await request.put({ url: '/cms/site/update', data })
}

// 删除站点
export const deleteSiteApi = async (id: number) => {
  return await request.delete({ url: '/cms/site/delete?id=' + id })
}

// 导出站点 Excel
export const exportSiteApi = async (params: SiteExcelReqVO) => {
  return await request.download({ url: '/cms/site/export-excel', params })
}

// 查询站点基本配置详情
export const getSiteBaseConfigApi = async (id: number) => {
  return await request.get({ url: '/cms/site/config/get?id=' + id })
}
// 修改站点基本配置
export const updateSiteBaseConfigApi = async (data: SiteBaseConfigReqVO) => {
  return await request.post({ url: '/cms/site/config/update', data })
}

// 查询站点默认模板详情
export const getSiteTplConfigApi = async (params: SiteDefTplQueryVO) => {
  return await request.get({ url: '/cms/site/config/defTpl/get', params })
}
// 修改站点默认模板配置
export const updateSiteTplConfigApi = async (data: SiteDefTplReqVO) => {
  return await request.post({ url: '/cms/site/config/defTpl/update', data })
}
